FROM centos:6

RUN yum install -y --nogpgcheck tar gcc bison re2c file libcurl-devel openssl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel curl-devel libxslt-devel ImageMagick-devel

RUN curl -O http://cn2.php.net/distributions/php-7.0.1.tar.gz \
    && tar -zxvf php-7.0.1.tar.gz \
    && rm -f php-7.0.1.tar.gz \
    && cd php-7.0.1 \
    && ./configure --prefix=/usr/local/php \
    --exec-prefix=/usr/local/php \
    --bindir=/usr/local/php/bin \
    --sbindir=/usr/local/php/sbin \
    --includedir=/usr/local/php/include \
    --libdir=/usr/local/php/lib/php \
    --mandir=/usr/local/php/php/man \
    --with-config-file-path=/usr/local/php/etc \
    --with-curl \
    --with-freetype-dir \
    --with-gd \
    --with-gettext \
    --with-iconv-dir \
    --with-kerberos \
    --with-libdir=lib64 \
    --with-libxml-dir \
    --with-mysqli \
    --with-openssl \
    --with-pcre-regex \
    --with-pdo-mysql \
    --with-pdo-sqlite \
    --with-pear \
    --with-png-dir \
    --with-xmlrpc \
    --with-xsl \
    --with-zlib \
    --enable-fpm \
    --enable-bcmath \
    --enable-libxml \
    --enable-inline-optimization \
    --enable-gd-native-ttf \
    --enable-mbregex \
    --enable-mbstring \
    --enable-opcache \
    --enable-pcntl \
    --enable-shmop \
    --enable-soap \
    --enable-sockets \
    --enable-sysvsem \
    --enable-xml \
    --enable-zip \
    && make && make install \
    && cp php.ini-production /usr/local/php/etc/php.ini \
    && cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
    && cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
    && make distclean \
    && rm -rf php-7.0.1

RUN sed -e 's/127.0.0.1:9000/9000/' \
        -e '/allowed_clients/d' \
        -e '/catch_workers_output/s/^;//' \
        -e '/daemonize/s/yes/no/' \
        -e '/error_log/d' \
        -i /usr/local/php/etc/php-fpm.d/www.conf

EXPOSE 9000

CMD ["/usr/local/php/sbin/php-fpm","-F"]